package com.qianbao.dao.money;


import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

@Mapper
@Repository
public interface CoinDao {


    /**
     * 保存金币数量，更新金币数量
     * @param custom_id
     * @param coin
     * @return
     */
    @Insert("INSERT INTO sys_user_coin (coin,custom_id) VALUES (#{coin},#{custom_id}) ON DUPLICATE KEY UPDATE coin = coin + #{coin}")
    public int saveUserCoin(@Param("custom_id")String custom_id, @Param("coin")int coin);


    /**
     * 查询
     * @param custom_id
     * @return
     */
    @Select("SELECT IFNULL(MAX(coin),0) FROM sys_user_coin WHERE custom_id = #{custom_id}")
    public int findUserCoin(String custom_id);


}
